package com.cloudcross.ssp.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloudcross.ssp.base.dao.GenericIBatisDao;
import com.cloudcross.ssp.model.AccountAuthority;
import com.cloudcross.ssp.model.RoleAccount;
import com.cloudcross.ssp.model.Roles;
import com.cloudcross.ssp.service.IAccountAuthorityService;
import com.cloudcross.ssp.web.widget.SelectorController.ISelector;
import com.cloudcross.ssp.web.widget.SelectorController.ISelectorProvider;


@Service
public class AccountAuthorityService implements IAccountAuthorityService, ISelectorProvider {

    @Autowired
    private GenericIBatisDao myBatisDao;

    @Override
    public List<AccountAuthority> findAllAccountAuthority() {
        return myBatisDao.getList("accountAuthoritySqlMapper.selectAllAccountAuthority");
    }


    @Override
    public int countByParams(Map<String, Object> paramMap) {
        return myBatisDao.get("accountAuthoritySqlMapper.countByParams", paramMap);
    }

    @Override
    public List<AccountAuthority> findByParams(Map<String, Object> paramMap) {
        return myBatisDao.getList("accountAuthoritySqlMapper.selectByParams", paramMap);
    }

    @Override
    public Map<String, List<? extends ISelector>> provideData(String[] parentId) {
        return null;
    }

    @Override
    public List<Roles> findAllRoles() {
        return myBatisDao.getList("accountAuthoritySqlMapper.selectAllRoles");
    }


    @Override
    public AccountAuthority findByAccountId(Long accountId) {
        return myBatisDao.get("accountAuthoritySqlMapper.findByAccountId", accountId);
    }


    @Override
    public List<Long> findRolesResources(Long roleId) {
        return myBatisDao.getList("accountAuthoritySqlMapper.selectRolesResources", roleId);
    }

    @Override
    public RoleAccount queryAccountRoleByCondition(Map<String, Object> condition) {
        return myBatisDao.get("accountAuthoritySqlMapper.queryAccountRoleByCondition", condition);
    }

}
